<?php
/* adminheader,inc 2006-07-02 12:48:44
   Conference Registration - Registration for conferences - A XOOPS CMS Module
   Copyright (c) 2006 Kevin van Haaren, US
   URL:     http://www.superfantasmoworld.com/
   Contact: kevin@vanhaaren.net
 	
   XOOPS
   Copyright (c) 2000 XOOPS.org
   URL:     http://www.xoops.org/
    
   This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    
 */
 
//The next comment block is for PHPDocumentor
/**
 * Conference Registration - Registration for conferences
 * 
 * Administration pages header script
 * 
 * @author Kevin van Haaren (kevin@vanhaaren.net)
 * @copyright 2006 Kevin van Haaren, US
 * @package CONFREG
 * @subpackage Admin
 * 
 */

/**
* The control panel header script that:
*
* - includes Xoops mainfile.php
* - includes cp_functions.php (control panel functions declarations)
* - checks access rights to the page and denies if no right
* - sets up var $xoopsModule object to point to current module
* - sets up var $xoopsModuleConfig object to hold current module configuration parameters
* - loads up the default language file for admin interface
*/
include_once "../../../include/cp_header.php";

/**
* @global object Xoops user object
* @global object Xoops main configuration object
* @global object This module's configuration object
* @global object This module
* @global object Xoops database object
*/
global $xoopsUser, $xoopsConfig, $xoopsModuleConfig, $xoopsModule;
global $xoopsDB;

/**
* Function: Creates a pretty menu and navigation bar above your module admin page 
*
* I've nicked the basis of this from functions.php,v 1.2 of the new Profiles module
* developed by hyperpod for Xoops V1.2
*
* @version 1
* @author hyperpod (parts) A Kitson (parts)
* @param int $currentoption The menu option to display as being current
* @param string $breadcrumb the trail back to where we've come from
*/

function xoops_module_admin_menu ($currentoption = 0, $breadcrumb = '')
{
	/**
	* @global object This module object
	* @global object Xoops config parameter object
	*/
	global $xoopsModule, $xoopsConfig;
	$configStr = ''; 
	
	/**
	* @var string module directory name
	*/
	$modDir = $xoopsModule->getVar("dirname");
	/**
	* @var string Set the path to the admin images directory
	*/
	$imagePath = XOOPS_URL."/modules/".$modDir."/admin/images/"; //<V2.1 version
	//$imagePath = XOOPS_URL."/images/admin/";  //V2.1 version
	/**
	* Load up the module installation constants so that when menu.php is included, the menu strings are set correctly
	*/
	$modDir = $xoopsModule->getVar("dirname");
	if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $modDir . '/language/' . $xoopsConfig['language'] . '/admin.php')) {
	   include_once XOOPS_ROOT_PATH . '/modules/' . $modDir . '/language/' . $xoopsConfig['language'] . '/admin.php';
	} else {
	   include_once XOOPS_ROOT_PATH . '/modules/' . $modDir . '/english/admin.php';
	}

	//include the default xoops language file for the admin interface
	//NOT required in this file for V2.1
	if ( file_exists( XOOPS_ROOT_PATH.'/modules/' . $modDir ."/language/" . $xoopsConfig['language'] . "/admin2.php" ) ) {
	    include XOOPS_ROOT_PATH.'/modules/' . $modDir ."/language/" . $xoopsConfig['language'] . "/admin2.php";
	}
	elseif ( file_exists( XOOPS_ROOT_PATH.'/modules/' . $modDir ."/language/english/admin.php2" ) ) {
	    include XOOPS_ROOT_PATH.'/modules/' . $modDir ."/language/english/admin2.php";
	}

	/**
	* Set up menu option display array
	*/
	include_once XOOPS_ROOT_PATH."/modules/".$modDir."/admin/menu.inc";
	
	//extend the menu option array to hold colour information
	// and strip out the /admin/ part of the link name
	$dispMenu = array();
	$c = 1;
	foreach ($adminmenu as $option) {
		$dispMenu[$c]["tblColour"]='';
		$arr = explode('/',$option['link']);
		$dispMenu[$c]["link"] = $arr[ count($arr)-1];
		$dispMenu[$c]["title"] = $option["title"];
		$c++;
	}
	//set the current option colour
	if ($currentoption > 0) {
		$dispMenu[$currentoption]["tblColour"] = "current";
	}
	
	//upper case the module directory
	$mdir = strtoupper($modDir);
	//set up vars from constant definitions
	/**
	* @var boolean has the module got documentation
	*/ 
	$hasDocs = defined("_AM_".$mdir."_URL_DOCS");
	/**
	* @var boolean has the module got support
	*/
	$hasSupport = defined("_AM_".$mdir."_URL_SUPPORT");
	/**
	* @var boolean Has the module got donations facility
	*/
	$hasDonations = defined("_AM_".$mdir."_URL_DONATIONS");
	
	if ($hasDocs) {
		/**
		* @var string Url of documentation
		*/
		$urlDocs = XOOPS_URL . '/modules/' . $modDir . "/" . constant("_AM_".$mdir."_URL_DOCS");
	}
	if ($hasSupport) {
		/**
		* @var string Url of support site
		*/
		$urlSupport = constant("_AM_".$mdir."_URL_SUPPORT");
	}
	if ($hasDonations) {
		/**
		* @var string Url of donations facility
		*/
		$urlDonations = constant("_AM_".$mdir."_URL_DONATIONS");
	}
	
	if (defined("_AM_".$mdir."_MODCONFIG")) {
		/**
		* @var string module config option
		*/
		$configType = constant("_AM_".$mdir."_MODCONFIG");
		/**
		* @var boolean does the module have any configuration
		*/
		$hasConfig = ($configType != 'none');
		if ($configType == "module") {
			/**
			* @var string name of callback function for module configuration
			*/
			$modConfigUrl = constant("_AM_".$mdir."_MODCONFIGURL");
		} 
	} else {
		$hasConfig = false;
	}	

	// Display the page header - don't ask me how this works I don't do CSS ! (AK)
	/* Nice buttons styles */
	echo "
    	<style type='text/css'>
    	#buttontop { float:left; width:100%; background: #e7e7e7; font-size:93%; line-height:normal; border-top: 1px solid black; border-left: 1px solid black; border-right: 1px solid black; margin: 0; }
    	#buttonbar { float:left; width:100%; background: #e7e7e7 url('" . $imagePath . "bg.gif') repeat-x left bottom; font-size:93%; line-height:normal; border-left: 1px solid black; border-right: 1px solid black; margin-bottom: 12px; }
    	#buttonbar ul { margin:0; margin-top: 15px; padding:10px 10px 0; list-style:none; }
		#buttonbar li { display:inline; margin:0; padding:0; }
		#buttonbar a { float:left; background:url('" . $imagePath . "left_both.gif') no-repeat left top; margin:0; padding:0 0 0 9px; border-bottom:1px solid #000; text-decoration:none; }
		#buttonbar a span { float:left; display:block; background:url('" . $imagePath . "right_both.gif') no-repeat right top; padding:5px 15px 4px 6px; font-weight:bold; color:#765; }
		/* Commented Backslash Hack hides rule from IE5-Mac \*/
		#buttonbar a span {float:none;}
		/* End IE5-Mac hack */
		#buttonbar a:hover span { color:#333; }
		#buttonbar #current a { background-position:0 -150px; border-width:0; }
		#buttonbar #current a span { background-position:100% -150px; padding-bottom:5px; color:#333; }
		#buttonbar a:hover { background-position:0% -150px; }
		#buttonbar a:hover span { background-position:100% -150px; }
		</style>
    ";
	
	
	$myts =& MyTextSanitizer::getInstance();
	
	echo "<div id='buttontop'>";
	echo "<table style=\"width: 100%; padding: 0; \" cellspacing=\"0\"><tr>";
	echo "<td style=\"width: 70%; font-size: 10px; text-align: left; color: #2F5376; padding: 0 6px; line-height: 18px;\">";
	if ($hasConfig) {
		$configStr = "<a class=\"nobutton\" href=";
		if ($configType == "xoops") {
			$configStr .=  "\"../../system/admin.php?fct=preferences&amp;op=showmod&amp;mod=" . $xoopsModule->getVar('mid') . "\">";
		} else {
			$configStr .= "\"". $modConfigUrl ."\">";
		}
		$configStr .= _AD_MOD_CONFIG . "</a> | ";
	}
	echo $configStr;
	echo "<a href=\"../index.php\">" . _AD_MOD_HOME . "</a>";
	if ($hasDocs) {
		echo " | <a target=\"_blank\" href=\"".$urlDocs."\">" . _AD_DOCS . "</a>";
	}
	if ($hasSupport) {
		echo " | <a target=\"_blank\" href=\"".$urlSupport."\">" . _AD_SUPPORT . "</a>";
	}
	if ($hasDonations) {
		echo  " | <a target=\"_blank\" href=\"".$urlDonations."\">" . _AD_DONATIONS . "</a>";
	}
	echo "</td>";
	echo "<td style=\"width: 30%; font-size: 10px; text-align: right; color: #2F5376; padding: 0 6px; line-height: 18px;\"><b>" . $myts->displayTarea($xoopsModule->getVar("name")) . " " . _AD_MODADMIN . "</b> " . $breadcrumb . "</td>";
	echo "</tr></table>";
	echo "</div>";
	echo "<div id='buttonbar'>";
	echo "<ul>";
	foreach ($dispMenu as $option) {
		echo "<li id='" . $option["tblColour"] . "'><a href='".$option["link"]."'><span>" . $option["title"] . "</span></a></li>";
	}
	echo "</ul></div><p>";
	echo "<br /><br /><pre>&nbsp;</pre><pre>&nbsp;</pre>";
}


// Load up the module language constants
$modDir = $xoopsModule->getVar("dirname");
$modLang = $xoopsConfig['language'];

if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $modDir . '/language/' . $modLang . '/main.php')) {
   include_once XOOPS_ROOT_PATH . '/modules/' . $modDir . '/language/' . $modLang . '/main.php';
} else {
	/**
	* @ignore 
	*/
    include_once XOOPS_ROOT_PATH . '/modules/' . $modDir . '/english/main.php';
}

if ( file_exists( XOOPS_ROOT_PATH."/modules/" . $modDir . "/language/" . $modLang . "/admin.php" ) ) {
	/**
 	* Include menu language definitions
 	*/
    include_once XOOPS_ROOT_PATH."/modules/" . $modDir . "/language/" . $modLang . "/admin.php";
}
elseif ( file_exists( XOOPS_ROOT_PATH."/modules/" . $modDir . "/language/english/admin.php" ) ) {
	/**
	 * @ignore 
	 */
    include_once XOOPS_ROOT_PATH."/modules/" . $modDir . "/language/english/admin.php";
}

/**
* Module main header
*/
require_once "../header.inc";
/**
* Module admin special functions
*/
require_once "functions.inc"; 

/**
* Put below any other includes you need for your admin pages to work.
* These might include some specialised functions or class declarations
*/


/**
* Call the admin page header function
*/
//xoops_cp_header();

/*
 * This file was generated by XBS ModGen, (c) 2006 A Kitson, UK. See http://xoobs.net
 * ModGen is a Module Code Generator for the Xoops CMS.  See http://xoops.org
 */
?>